home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / Implementation / Core / Info.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-13  |  8.7 KB  |  418 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Info.cpp
  3.  
  4.     Contains:    implementation of the Info object including ShowPartFrameInfo
  5.  
  6.     Owned by:    Ed Lai
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <21>      12/19/96    eeh        1614389: return false if user cancels
  13.         <20>     9/24/96    eeh        1315228: cleanup
  14.         <19>     9/10/96    eeh        1386008: AppleGuide support (incomplete)
  15.         <18>     6/22/96    EL        1344140: dialogLib's ShowPartFrameInfo now
  16.                                     returns ODError.
  17.         <17>     6/21/96    jpa        T10002: Changed min/default heap size.
  18.                                     (Also improved debug msg from
  19.                                     GetSharedLibrary.)
  20.         <16>      6/7/96    eeh        T10017: function ptrs must be extern C
  21.         <15>      6/7/96    eeh        T10017: use current architecture
  22.         <14>      6/7/96    eeh        T10017: return CFM errors
  23.         <13>      6/7/96    eeh        T10017: move most dlg stuff to InfoDlg.cpp
  24.         <12>      6/5/96    EL        1355529: Use menu item count to determine
  25.                                     the translation menu item.
  26.         <11>      6/4/96    EL        1323543: Remove some unneeded comment from
  27.                                     last check in.
  28.         <10>      6/4/96    EL        1323543: Bundled checkbox is now two radio
  29.                                     buttons. 1289557: Alert for bad file name
  30.                                     and comment too long.
  31.          <9>     5/30/96    CC        1299865: ShowPartFrameInfo: If the kind
  32.                                     popup is changed, keep the same editor
  33.                                     unless it doesn't support the new kind.
  34.          <8>     5/29/96    TJ        Worked around temp var scoping problem.
  35.          <7>     5/28/96    EL        #1234149: Remove staticText covering
  36.                                     checkbox so that checkbox can be shown as
  37.                                     dimmed for read only document.
  38.          <6>     5/24/96    jpa        1246074: Fix SOM_CATCH. Also: Disable CW
  39.                                     optimizer on GetPartFrameInfo to avoid CW8
  40.                                     compiler crashes.
  41.          <5>     5/22/96    EL        #1263100: If cancel out of SynchNSTable,
  42.                                     reraise the error.
  43.          <4>      5/3/96    EL        1313942: release settings extension before
  44.                                     editor is swapped. 1329522: document info
  45.                                     size dialog button will be inverted on
  46.                                     mouse down to give user feedback.
  47.          <3>     3/20/96    EL        1289563: for read-only field from read-only
  48.                                     documents, disallow editing. Allow viewing
  49.                                     of heap size info from read-only document
  50.                                     but don't allow editing.
  51.          <2>     1/12/96    CC        1302700: ShowPartFrameInfo: Show part id if
  52.                                     frame is non-persistent.
  53.                                     1295846:  ShowPartFrameInfo: ASSERT that
  54.                                     part is a part wrapper.
  55.  
  56.     In Progress:
  57.         
  58. */
  59.  
  60. #define _USE_DIALOGS_LIB_
  61.  
  62. #define ODInfo_Class_Source
  63. #define VARIABLE_MACROS
  64. #include <Info.xih>
  65.  
  66. #ifndef _USERSRCM_
  67. #include <UseRsrcM.h>
  68. #endif
  69.  
  70. #ifndef SOM_ODSession_xh
  71. #include <ODSessn.xh>
  72. #endif
  73.  
  74. #ifndef SOM_ODDraft_xh
  75. #include <Draft.xh>
  76. #endif
  77.  
  78. #ifndef SOM_ODDocument_xh
  79. #include <Document.xh>
  80. #endif
  81.  
  82. #ifndef SOM_ODContainer_xh
  83. #include <ODCtr.xh>
  84. #endif
  85.  
  86. #ifndef SOM_ODWindowState_xh
  87. #include <WinStat.xh>
  88. #endif
  89.  
  90. #ifndef SOM_ODWindow_xh
  91. #include <Window.xh>
  92. #endif
  93.  
  94. #ifndef SOM_ODFrameFacetIterator_xh
  95. #include <FrFaItr.xh>
  96. #endif
  97.  
  98. #ifndef _INFODEFS_
  99. #include <InfoDefs.h>
  100. #endif
  101.  
  102. #ifndef _PREFS_
  103. #include "Prefs.h"
  104. #endif
  105.  
  106. #ifndef SOM_Module_OpenDoc_StdProps_defined
  107. #include <StdProps.xh>
  108. #endif
  109.  
  110. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  111. #include <StdTypes.xh>
  112. #endif
  113.  
  114. #ifndef _ODUTILS_
  115. #include <ODUtils.h>
  116. #endif
  117.  
  118. #ifndef SOM_ODFrame_xh
  119. #include <Frame.xh>
  120. #endif
  121.  
  122. #ifndef SOM_ODFacet_xh
  123. #include <Facet.xh>
  124. #endif
  125.  
  126. #ifndef SOM_ODPart_xh
  127. #include <Part.xh>
  128. #endif
  129.  
  130. #ifndef SOM_ODStorageUnit_xh
  131. #include <StorageU.xh>
  132. #endif
  133.  
  134. #ifndef SOM_ODStorageUnitView_xh
  135. #include <SUView.xh>
  136. #endif
  137.  
  138. #ifndef SOM_ODSettingsExtension_xh
  139. #include <Settings.xh>
  140. #endif
  141.  
  142. #ifndef SOM_Module_OpenDoc_StandardExtensions_defined
  143. #include <StdExts.xh>
  144. #endif
  145.  
  146. #ifndef _PASCLSTR_
  147. #include <PasclStr.h>
  148. #endif
  149.  
  150. #ifndef _ODMEMORY_
  151. #include <ODMemory.h>
  152. #endif
  153.  
  154. #ifndef _PLFMFILE_
  155. #include <PlfmFile.h>
  156. #endif
  157.  
  158. #ifndef SOM_ODTypeList_xh
  159. #include <TypeList.xh>
  160. #endif
  161.  
  162. #ifndef SOM_ODTypeListIterator_xh
  163. #include <TypLsItr.xh>
  164. #endif
  165.  
  166. #ifndef _BINDNGH_
  167. #include <BindngH.h>
  168. #endif
  169.  
  170. #ifndef _BNDNSUTL_
  171. #include <BndNSUtl.h>
  172. #endif
  173.  
  174. #ifndef _DLOGUTIL_
  175. #include <DlogUtil.h>
  176. #endif
  177.  
  178. #ifndef _DOCUTILS_
  179. #include <DocUtils.h>
  180. #endif
  181.  
  182. #ifndef _TEMPOBJ_
  183. #include <TempObj.h>
  184. #endif
  185.  
  186. #ifndef _EXCEPT_
  187. #include <Except.h>
  188. #endif
  189.  
  190. #ifndef _ITEXT_
  191. #include <IText.h>
  192. #endif
  193.  
  194. #ifndef _STORUTIL_
  195. #include <StorUtil.h>
  196. #endif
  197.  
  198. #ifndef _EDITRSET_
  199. #include <EditrSet.h>
  200. #endif
  201.  
  202. #ifndef _ISOSTR_
  203. #include <ISOStr.h>
  204. #endif
  205.  
  206. #ifdef __SC__
  207. #ifndef __PACKAGES__
  208. #include <Packages.h>
  209. #endif
  210. #else
  211. #ifndef __TEXTUTILS__
  212. #include <TextUtils.h>
  213. #endif
  214. #endif
  215.  
  216. #ifndef __STRING__
  217. #include <String.h>
  218. #endif
  219.  
  220. #ifndef __GESTALTEQU__
  221. #include <GestaltEqu.h>
  222. #endif
  223.  
  224. #ifndef __DIALOGS__
  225. #include <Dialogs.h>
  226. #endif
  227.  
  228. #ifndef __TEXTEDIT__
  229. #include <TextEdit.h>
  230. #endif
  231.  
  232. #ifndef __TOOLUTILS__
  233. #include <ToolUtils.h>
  234. #endif
  235.  
  236. #ifndef __FONTS__
  237. #include <Fonts.h>
  238. #endif
  239.  
  240. #ifndef __CONTROLS__
  241. #include <Controls.h>
  242. #endif
  243.  
  244. #ifndef SOM_ODPartWrapper_xh
  245. #include <PartWrap.xh>
  246. #endif
  247.  
  248. #ifndef _INFOUTIL_
  249. #include <InfoUtil.h>
  250. #endif
  251.  
  252. #ifndef _STDTYPIO_
  253. #include <StdTypIO.h>
  254. #endif
  255.  
  256. #ifndef _TEMPOBJ_
  257. #include <TempObj.h>
  258. #endif
  259.  
  260. #ifndef SOM_ODTranslation_xh
  261. #include <Translt.xh>
  262. #endif
  263.  
  264. #ifndef SOM_ODDispatcher_xh
  265. #include <Disptch.xh>
  266. #endif
  267.  
  268. #ifndef __PALETTES__
  269. #include <Palettes.h>
  270. #endif
  271.  
  272. #ifndef __ICONS__
  273. #include <Icons.h>
  274. #endif
  275.  
  276. #ifndef __FOLDERS__
  277. #include <Folders.h>
  278. #endif
  279.  
  280. #ifndef _TRANSUTL_
  281. #include <TransUtl.h>
  282. #endif
  283.  
  284. #ifndef __MENUS__
  285. #include <Menus.h>
  286. #endif
  287.  
  288. #ifndef SOM_ODStorageSystem_xh
  289. #include <ODStor.xh>
  290. #endif
  291.  
  292. #ifndef SOM_ODNameSpaceManager_xh
  293. #include <NmSpcMg.xh>
  294. #endif
  295.  
  296. #ifndef _ORDCOLL_
  297. #include "OrdColl.h"
  298. #endif
  299.  
  300. #pragma segment ODInfo
  301.  
  302. #ifdef _USE_DIALOGS_LIB_
  303.  
  304. //==============================================================================
  305. // InitInfo
  306. //==============================================================================
  307.  
  308. SOM_Scope void  SOMLINK ODInfoInitInfo(ODInfo *somSelf, Environment *ev,
  309.         ODSession* session)
  310. {
  311.     ODInfoData *somThis = ODInfoGetData(somSelf);
  312.     ODInfoMethodDebug("ODInfo","ODInfoInitInfo");
  313.     
  314.     _fSession = session;
  315. //    gSession = _fSession;
  316. }
  317.  
  318. //==============================================================================
  319. // ShowPartFrameInfo
  320. //==============================================================================
  321.  
  322. static pascal ODBoolean CallCheckScriptFirstThenStdFilterProc( DialogPtr dialog,
  323.         EventRecord *event, short *itemHit)
  324. {
  325.     return CheckKeyScriptChangeFilterProc( dialog, event, itemHit )
  326.         || ODDialogFilterProc( dialog, event, itemHit );
  327. }
  328.  
  329. // <eeh> this ought to be moved to a utility file at some point
  330. OSErr LoadODSharedLibrary( Str63 libName, Str255 entryName,
  331.         CFragConnectionID* connID, void** entryPoint );
  332. OSErr LoadODSharedLibrary( Str63 libName, Str255 entryName,
  333.         CFragConnectionID* connID, void** entryPoint )
  334. {
  335.     Ptr ignore;
  336.     Str255 errName;
  337. //    CFragConnectionID connID;
  338.  
  339.     OSErr err = GetSharedLibrary( libName, kCurrentCFragArch, 1, connID,
  340.             &ignore, errName );
  341.     if ( err == noErr )
  342.     {
  343.         CFragSymbolClass symClass;
  344.         err = FindSymbol( *connID, entryName, (Ptr*)entryPoint, &symClass );
  345.         if ( err == noErr )
  346.             WASSERT( symClass == kTVectorCFragSymbol );
  347.         else
  348.         {
  349.             WARN( "Didn't find symbol address" );
  350.             *entryPoint = kODNULL;
  351.         }
  352.     }
  353.     else
  354.     {
  355. #if ODDebug
  356.         PascalToCString( errName );
  357.         WARN( "GetSharedLibrary returned error %d '%s'", err, errName );
  358. #endif
  359.     }
  360.  
  361.     return err;
  362. }
  363.  
  364. void UnloadODSharedLibrary( CFragConnectionID* connID );
  365. void UnloadODSharedLibrary( CFragConnectionID* connID )
  366. {
  367.     OSErr err = CloseConnection( connID );
  368.     WASSERT( err == noErr );
  369. }
  370.  
  371. #ifdef __cplusplus
  372. extern "C" {
  373. #endif
  374. typedef ODError (*InfoDialogEntry)( Environment *ev,
  375.         ODSession* session, ODFacet* facet, ODBoolean allowEditing);
  376. #ifdef __cplusplus
  377. }
  378. #endif
  379.  
  380. SOM_Scope ODBoolean  SOMLINK ODInfoShowPartFrameInfo(ODInfo *somSelf, Environment *ev,
  381.         ODFacet* facet, ODBoolean allowEditing)
  382. {
  383.     ODInfoData *somThis = ODInfoGetData(somSelf);
  384.     ODInfoMethodDebug("ODInfo","ODInfoShowPartFrameInfo");
  385.  
  386.     // already volatile since address taken....
  387.     InfoDialogEntry ide = kODNULL; ODVolatile( ide );
  388.     CFragConnectionID connID; ODVolatile( connID );
  389.     ODBoolean result = kODFalse; ODVolatile(result);
  390.  
  391.     SOM_TRY
  392.         ODError    error = 0;
  393.         THROW_IF_ERROR( LoadODSharedLibrary( "\pDialogsLib",
  394.                 "\pShowPartFrameInfo", &connID, (void**)&ide ) );
  395.         error = (*ide)( ev, _fSession, facet, allowEditing );
  396.         if (error && (error != userCanceledErr))
  397.             THROW(error);
  398.         UnloadODSharedLibrary( &connID );
  399.         result = error != userCanceledErr;
  400.     SOM_CATCH_ALL
  401.         if ( ide != kODNULL )        // we loaded the library
  402.             UnloadODSharedLibrary( &connID );
  403.         // reraise happens automatically
  404.     SOM_ENDTRY
  405.     return result;
  406. }
  407.  
  408. SOM_Scope void  SOMLINK ODInfosomUninit(ODInfo *somSelf)
  409. {
  410.     //ODInfoData *somThis = ODInfoGetData(somSelf);
  411.     ODInfoMethodDebug("ODInfo","ODInfosomUninit");
  412.  
  413.     ODInfo_parent_ODObject_somUninit(somSelf);
  414. }
  415.  
  416. #else
  417.     error will robinson; don't compile me!!!
  418. #endif